package com.fang.excel.controller;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class SingleThreadExecutorExample {
    public static void main(String[] args) {
        ExecutorService executor = Executors.newSingleThreadExecutor();

        executor.execute(() -> {
            System.out.println("任务 1 由线程 " + Thread.currentThread().getName() + " 执行");
        });

        executor.execute(() -> {
            System.out.println("任务 2 由线程 " + Thread.currentThread().getName() + " 执行");
        });

        executor.shutdown(); // 关闭线程池
    }
}
